package com.dkd.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dkd.common.annotation.Log;
import com.dkd.common.core.controller.BaseController;
import com.dkd.common.core.domain.AjaxResult;
import com.dkd.common.enums.BusinessType;
import com.dkd.manage.domain.ZichanType;
import com.dkd.manage.service.IZichanTypeService;
import com.dkd.common.utils.poi.ExcelUtil;
import com.dkd.common.core.page.TableDataInfo;

/**
 * 资产类型管理Controller
 *
 * @author zqy
 * @date 2024-12-25
 */
@Api(tags = "资产类型管理Controller")
@RestController
@RequestMapping("/manage/zichanType")
public class ZichanTypeController extends BaseController
{
    @Autowired
    private IZichanTypeService zichanTypeService;

/**
 * 查询资产类型管理列表
 */
@ApiOperation("查询资产类型管理列表")
@PreAuthorize("@ss.hasPermi('manage:zichanType:list')")
@GetMapping("/list")
    public TableDataInfo list(ZichanType zichanType)
    {
        startPage();
        List<ZichanType> list = zichanTypeService.selectZichanTypeList(zichanType);
        return getDataTable(list);
    }

    /**
     * 导出资产类型管理列表
     */
    @ApiOperation("导出资产类型管理列表")
    @PreAuthorize("@ss.hasPermi('manage:zichanType:export')")
    @Log(title = "资产类型管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZichanType zichanType)
    {
        List<ZichanType> list = zichanTypeService.selectZichanTypeList(zichanType);
        ExcelUtil<ZichanType> util = new ExcelUtil<ZichanType>(ZichanType.class);
        util.exportExcel(response, list, "资产类型管理数据");
    }

    /**
     * 获取资产类型管理详细信息
     */
    @ApiOperation("获取资产类型管理详细信息")
    @PreAuthorize("@ss.hasPermi('manage:zichanType:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zichanTypeService.selectZichanTypeById(id));
    }

    /**
     * 新增资产类型管理
     */
    @ApiOperation("新增资产类型管理")
    @PreAuthorize("@ss.hasPermi('manage:zichanType:add')")
    @Log(title = "资产类型管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZichanType zichanType)
    {
        return toAjax(zichanTypeService.insertZichanType(zichanType));
    }

    /**
     * 修改资产类型管理
     */
    @ApiOperation("修改资产类型管理")
    @PreAuthorize("@ss.hasPermi('manage:zichanType:edit')")
    @Log(title = "资产类型管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZichanType zichanType)
    {
        return toAjax(zichanTypeService.updateZichanType(zichanType));
    }

    /**
     * 删除资产类型管理
     */
    @ApiOperation("删除改资产类型管理")
    @PreAuthorize("@ss.hasPermi('manage:zichanType:remove')")
    @Log(title = "资产类型管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zichanTypeService.deleteZichanTypeByIds(ids));
    }
}
